<template>
	<page-meta><navigation-bar title="免责声明" front-color="#ffffff" background-color="#046ef6" /></page-meta>
	<view>
		<iframe :src="linkurl" frameborder="0"></iframe>
		<view style="position: fixed;bottom: 0;left: 0;width: 100%;height: 40px;">
			<button @click="link" v-if="mstype" type="default" style="height: 40px;width: 100%;margin: 0 auto;border: 0;background: #046ef6;color: #fff;border-radius: 0;">阅读并同意</button>
			<text v-else style="position: absolute;width: 100%;top: 0;left: 0;display: block;text-align: center; height: 100%;background: #ccc;line-height: 40px;font-size: 16px;color: #666;">{{ms}}s后操作</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url:this.$store.state.url + '/api/shequuser/login/disclaimer',
				linkurl:'',
				ms:3,
				mstype:false
			}
		},
		methods: {
			link(){
				this.$store.state.vars = true;
				uni.setStorageSync('vars','123');
				uni.navigateBack();
			}
		},
		created() {
			var _this = this;
			// console.log(_this.url)
			var Time = setInterval(function(){
				if(_this.ms==0){
					clearInterval(Time);
					_this.mstype = true;
					return;
				};
				_this.ms = _this.ms - 1;
			},1000);
			uni.request({
				url: _this.url, 
				method: 'POST',
			
				success: res => {
					res = res.data;
					// console.log(res)
					if(res.code == 200){
						_this.linkurl = res.data;
					}
				},
				fail: res => {
					console.log(res);
				}
			});
		}
	}
</script>

<style>
iframe{width: 100%;height: calc(100% - 40px);position: fixed;top: 0;left: 0;}
</style>
